Garbage collected programming environments have been provided to free application developers from having to manage the use of memory by an application and its associated objects, subroutines, etc. In a typical garbage collected environment, a garbage collection module and/or process, provided as part of a run time environment, for example, periodically traverses a set of objects residing in memory (e.g., in a “heap” associated with a particular runtime system, such as the Java™ Virtual Machine) and frees memory associated with objects that are no longer being used by an application or any other object or process. In some systems, a garbage collection includes a first stage in which the garbage collector traverses the objects in memory and marks those that are currently “reachable” from another “live” object and a second stage in which unmarked objects are “garbage collected”, i.e., in which memory previously allocated and used to store such objects is made available to be allocated for other use.
In some programming environments, for example those in which the amount of memory to be allocated to a new object is not determined dynamically at run time, the size of objects of one or more classes may be subject to some predefined limit. In such an environment it may not be practical to change the size, for example, of a class that has or may have been sub-classed by application developers, e.g., if such resizing may result in objects of such sub-classes not functioning properly. Techniques, such as instance variable repurposing and side tables, have been developed and used to store in an ancillary object or structure data that cannot be stored within the bounds of an object the size of which cannot be changed, e.g., new variables or parameters associated with additional methods that the class or related code has been extended to include. However, such techniques may be difficult to implement and/or may confound a garbage collector process or require the application developer to manage the relationships between objects and such ancillary structures, thereby depriving the developer of the full benefit of programming in a garbage collected environment.
Therefore, there is a need for a way to extend pre-existing object classes to include and/or be associated with additional data in a garbage collected programming environment.